﻿using System;

namespace Solution.Utilities
{
    public enum PageAction
    {
        New = 1,
        Edit = 2,
        Delete = 3,
        Save = 4
    };

    public static class StringExtensions
    {
        public static T ConvertToEnum<T>(this string value)
        {
            if (typeof(T).BaseType != typeof(Enum))
            {
                throw new InvalidCastException();
            }
            if (Enum.IsDefined(typeof(T), value) == false)
            {
                throw new InvalidCastException();
            }
            return (T)Enum.Parse(typeof(T), value);
        }
    }
}